package com.ybb.common.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;

public class DateUtils {

    /**
     * 回退daysToMinus天
     */
    public static LocalDateTime dateMinusDay(LocalDateTime date, int daysToMinus){
        LocalDateTime targetDate = date.minusDays(daysToMinus);
        return targetDate;
    }

    public static Date localDateTime2Date(LocalDateTime time){
        return Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
    }

    public static LocalDateTime todayBegin(){
        return LocalDate.now().atTime(LocalTime.MIDNIGHT);
    }

    public static void main(String[] args) {
        System.out.println(todayBegin());
    }
}
